#ifndef __THREAD_SYNC_H
#define __THREAD_SYNC_H

#include "stdint.h"
#include "list.h"
#include "thread.h"

struct semaphore{
    uint8_t value;
    struct list suspend_list;
};

struct lock{
    struct semaphore semaphore;
    /* 持有该锁的线程 */
    struct task_struct* holder;
    uint8_t holder_repeat_nr;
};


void sema_init(struct semaphore* psema, uint8_t value); 
void sema_down(struct semaphore* psema);
void sema_up(struct semaphore* psema);
void lock_init(struct lock* plock);
void lock_acquire(struct lock* plock);
void lock_release(struct lock* plock);

#endif